package com.ptszyxx.popose.module.main.home.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.databinding.ItemHomeAccountBinding;
import com.ptszyxx.popose.module.main.home.vm.HomeVM;
import com.ysg.http.data.entity.home.HomeAccountEntity;

public class HomeAccountAdapter extends BaseQuickAdapter<HomeAccountEntity, BaseDataBindingHolder<ItemHomeAccountBinding>> {

    private HomeVM viewModel;
    private Presenter mPresenter = new Presenter();

    public HomeAccountAdapter(HomeVM viewModel) {
        super(R.layout.item_home_account);
        this.viewModel = viewModel;
    }

    @Override
    protected void convert(BaseDataBindingHolder<ItemHomeAccountBinding> holder, HomeAccountEntity item) {
        ItemHomeAccountBinding binding = holder.getDataBinding();
        if (binding != null) {
            binding.setEntity(item);
            binding.setViewModel(viewModel);
            binding.setPresenter(mPresenter);
            binding.setPosition(holder.getBindingAdapterPosition());
            binding.executePendingBindings();
        }
    }

    public static class Presenter{
        public void onItemClick(HomeVM viewModel, HomeAccountEntity entity){
            viewModel.requestLogin(entity);
        }
    }







}
